package lc_1015_可被K整除的最小整数;

import java.util.HashSet;
import java.util.Set;

public class Solution {
	
	public int smallestRepunitDivByK(int k) {
		Set<Integer> set = new HashSet<>();
		int ans = 1, num = 1;
		while (set.add(num) && (num = num % k) != 0) {
			ans++;
			num = num * 10 + 1;
		}
		return num % k == 0 ? ans : -1;
	}
}
